/************************************************************************
  			hu/myai/model/TickValue.java - Copyright bozbalint

Here you can write a license for your code, some comments or any other
information you want to have in your generated code. To to this simply
configure the "headings" directory in uml to point to a directory
where you have your heading files.

or you can just replace the contents of this file with your own.
If you want to do this, this file is located at

/opt/kde3/share/apps/umbrello/headings/heading.java

-->Code Generators searches for heading files based on the file extension
   i.e. it will look for a file name ending in ".h" to include in C++ header
   files, and for a file name ending in ".java" to include in all generated
   java code.
   If you name the file "heading.<extension>", Code Generator will always
   choose this file even if there are other files with the same extension in the
   directory. If you name the file something else, it must be the only one with that
   extension in the directory to guarantee that Code Generator will choose it.

you can use variables in your heading files which are replaced at generation
time. possible variables are : author, date, time, filename and filepath.
just write %variable_name%

This file was generated on Sat Mar 14 2009 at 12:14:34
The original location of this file is /home/bozbalint/uml-generated-code/hu/myai/model/TickValue.java
 **************************************************************************/

package hu.myai.model;

import java.util.Date;

/**
 * Class TickValue
 * 
 * @author bozbalint
 * 
 */
public class TickVO implements Cloneable {

	private String symbol;

	private Double open;

	/**
	 * This cannot be null
	 */
	private double close;

	private Double high;

	private Double low;

	private Integer volume;

	/**
	 * This is a timestamp from 1970. Let java manage it as a Date
	 */
	private Date time;

	/**
	 * This is a relative time from project start up. Each tick will have unique
	 * timestamp. This means the number of the tick since the first tick.
	 */
	private int timestamp;

	/**
	 * It is the lenght of a tick: 1s, 5s, 1m, 15m, ...
	 */
	private int timeScale;

	public TickVO() {
	};

	public TickVO(Double open, Double high, Double low, double close, Integer volume, Date time, int timestamp) {
		this.open = open;
		this.close = close;
		this.high = high;
		this.low = low;
		this.volume = volume;
		this.time = time;
		this.timestamp = timestamp;
	}

	public TickVO clone() {
		try {
			return (TickVO) super.clone();
		} catch (CloneNotSupportedException e) {
			throw new RuntimeException("Tick is not clonable");
		}
	}

	/**
	 * Tick pivot: (high + low + close ) / 3
	 * */
	public double getPivot() {
		return (high + low + close) / 3;
	}

	/**
	 * Tick strength. How far it went further; open > close ? low : high
	 * */
	public double getStrength() {
		return open > close ? low : high;
	}

	/**
	 * @return the top value of the candle body
	 * */
	public double getBodyTop() {
		return open > close ? open : close;
	}

	/**
	 * @return the bottom value of the candle body
	 * */
	public double getBodyBottom() {
		return open < close ? open : close;
	}

	/**
	 * @return the center of tick gravity
	 * */
	public double getCenterOfGravity() {
		return (high + low + open + close) / 4;
	}

	/**
	 * @return the symbol
	 */
	public String getSymbol() {
		return symbol;
	}

	/**
	 * @param symbol
	 *            the symbol to set
	 */
	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}

	/**
	 * Set the value of open
	 * 
	 * @param open
	 *            the new value of open
	 */
	public void setOpen(Double open) {
		this.open = open;
	}

	/**
	 * Get the value of open
	 * 
	 * @return the value of open
	 */
	public Double getOpen() {
		return open;
	}

	/**
	 * Set the value of close This cannot be null
	 * 
	 * @param close
	 *            the new value of close
	 */
	public void setClose(double close) {
		this.close = close;
	}

	/**
	 * Get the value of close This cannot be null
	 * 
	 * @return the value of close
	 */
	public double getClose() {
		return close;
	}

	/**
	 * Set the value of high
	 * 
	 * @param high
	 *            the new value of high
	 */
	public void setHigh(Double high) {
		this.high = high;
	}

	/**
	 * Get the value of high
	 * 
	 * @return the value of high
	 */
	public Double getHigh() {
		return high;
	}

	/**
	 * Set the value of low
	 * 
	 * @param low
	 *            the new value of low
	 */
	public void setLow(Double low) {
		this.low = low;
	}

	/**
	 * Get the value of low
	 * 
	 * @return the value of low
	 */
	public Double getLow() {
		return low;
	}

	/**
	 * Set the value of volume
	 * 
	 * @param volume
	 *            the new value of volume
	 */
	public void setVolume(Integer volume) {
		this.volume = volume;
	}

	/**
	 * Get the value of volume
	 * 
	 * @return the value of volume
	 */
	public Integer getVolume() {
		return volume;
	}

	/**
	 * Set the value of time This is a timestamp from 1970. Let java manage it
	 * as a Date
	 * 
	 * @param time
	 *            the new value of time
	 */
	public void setTime(Date time) {
		this.time = time;
	}

	/**
	 * Get the value of time This is a timestamp from 1970. Let java manage it
	 * as a Date
	 * 
	 * @return the value of time
	 */
	public Date getTime() {
		return time;
	}

	/**
	 * Set the value of timestamp This is a relative time from project start up.
	 * Each tick will have unique timestamp. This means the number of the tick
	 * since the first tick.
	 * 
	 * @param timestamp
	 *            the new value of timestamp
	 */
	public void setTimestamp(int timestamp) {
		this.timestamp = timestamp;
	}

	/**
	 * Get the value of timestamp This is a relative time from project start up.
	 * Each tick will have unique timestamp. This means the number of the tick
	 * since the first tick.
	 * 
	 * @return the value of timestamp
	 */
	public int getTimestamp() {
		return timestamp;
	}

	/**
	 * Set the value of timeScale It is the lenght of a tick: 1s, 5s, 1m, 15m,
	 * ...
	 * 
	 * @param timeScale
	 *            the new value of timeScale
	 */
	public void setTimeScale(int timeScale) {
		this.timeScale = timeScale;
	}

	/**
	 * Get the value of timeScale It is the lenght of a tick: 1s, 5s, 1m, 15m,
	 * ...
	 * 
	 * @return the value of timeScale
	 */
	public int getTimeScale() {
		return timeScale;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((symbol == null) ? 0 : symbol.hashCode());
		result = prime * result + ((time == null) ? 0 : time.hashCode());
		result = prime * result + timestamp;
		result = prime * result + timeScale;
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TickVO other = (TickVO) obj;
		if (symbol == null) {
			if (other.symbol != null)
				return false;
		} else if (!symbol.equals(other.symbol))
			return false;
		if (time == null) {
			if (other.time != null)
				return false;
		} else if (!time.equals(other.time))
			return false;
		if (timeScale != other.timeScale)
			return false;
		if (timestamp != other.timestamp)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "[o=" + open + ",c=" + close + ",h=" + high + ",l=" + low + ",v=" + volume + ",time=" + timestamp + ",d=" + time + ",s=" + symbol
				+ "]";
	}
}
